<?php

class model_vsAccountCookie extends L {

    /**
     * 描述 ：分页的查询语句拼接
     * 作者 ：Zoro.Zhu
    **/
    public static function searchSql($params = array()){
        $sql = "SELECT
             `id`, `account`, `cookie`, `addDate`, `addName`, `closePbAds`, `phone`
        FROM
            `vs_account_cookie`
        WHERE 1";
        $sql .= " AND addName = '" . core_base::getUser('name') ."'";
        $sql .= !empty($params['search']['account']) ? " AND `account` LIKE '%{$params['search']['account']}%' " : "";
        return $sql;
    }

    /**
     * 描述 ：执行修改数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function updateSql($data = array()){
        $date = date('Y-m-d H:i:s');
        $sql = "UPDATE `vs_account_cookie` 
        SET 
            `account` = '{$data['account']}',
            `cookie` = '{$data['cookie']}',
            `closePbAds` = '{$data['closePbAds']}',
            `phone` = '{$data['phone']}',
            `addDate` = '{$date}'
        WHERE
            `id` = '{$data['id']}'";
        return L::sql($sql);
    }

    /**
     * 描述 ：执行插入数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function insertSql($data = array()){
        $name = core_base::getUser('name');
        $date = date('Y-m-d H:i:s');
        $sql = "INSERT INTO `vs_account_cookie`(
             `account`, `cookie`, `addDate`, `addName`, `closePbAds`, `phone`
        ) VALUES (
             '{$data['account']}', '{$data['cookie']}', '{$date}', '{$name}', '{$data['closePbAds']}', '{$data['phone']}'
        )";
        return L::sql($sql);
    }

    /**
     * 描述：根据主键获取数据
     * 作者：Zoro.Zhu
    **/
    public static function getKeyInfo($key){
        $sql = "SELECT
             `id`, `account`, `cookie`, `addDate`, `addName`, `closePbAds`,`phone`
        FROM
            `vs_account_cookie`
        WHERE 
            `id` = '{$key}'";
        return L::sql($sql);
    }

}